#include <QCoreApplication>
#include <qprocess.h>
#include <QTextCodec>
#include <QDebug>

int main(void)
{
//    QCoreApplication a(argc, argv);

//    return a.exec();
    QString program = "C:/Windows/System32/cmd.exe";
    QStringList arguments;
    arguments << "/c" << "dir" << "C:\\";
    QProcess *cmdProcess = new QProcess;
    QObject::connect(cmdProcess, &QProcess::readyRead, [=] () {
        QTextCodec *codec = QTextCodec::codecForName("GBK");
        QString dir = codec->toUnicode(cmdProcess->readAll());
        qDebug() << dir;
    });
    cmdProcess->start(program, arguments);
    return 0;
}
